<template>
	<div>
		<el-drawer title="" :visible.sync="drawer" :direction="direction" :before-close="handleClose" custom-class="drawer-info">
			<div class="info-item">
				<h5 class="from-title">基本信息</h5>
				<div class="form-item">
					<label class="form-item-label">配置名称:</label>
					<div class="form-item-content">{{ objInfo.name }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">标签名称:</label>
					<div class="form-item-content">{{ objInfo.tagName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">选值类型:</label>
					<div class="form-item-content">{{ objInfo.valueTypeName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">选值范围:</label>
					<div class="form-item-content">{{ objInfo.tagValues }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">修改人:</label>
					<div class="form-item-content">{{ objInfo.updateUser == -1 ? "" : objInfo.updateUser }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">修改时间:</label>
					<div class="form-item-content">{{ objInfo.updateTime }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">标签分组:</label>
					<div class="form-item-content">{{ objInfo.tagGroupName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">排序:</label>
					<div class="form-item-content">{{ objInfo.sort }}</div>
				</div>
			</div>
		</el-drawer>
	</div>
</template>
<script>
import { cmsconfigInfo } from "@/api/cms/cmsconfig.js"
import {dictList, enumList} from "@/api/public.api.js"
export default {
	data() {
		return {
			drawer: true,
			direction: "rtl",
			objInfo: {},
			ConfigValueType_cmsList: [],
			TagGroup_cmsList: [],
		}
	},
	created() {},
	methods: {
		queryEnumList() {
			this.ConfigValueType_cmsList = []
			enumList("ConfigValueType", "cms").then(resp => {
				if (resp.code == 0) {
					this.ConfigValueType_cmsList = resp.data
				}
			})
			this.TagGroup_cmsList = []
      dictList("config_tag_group").then(resp => {
				if (resp.code == 0) {
					this.TagGroup_cmsList = resp.data
				}
			})
		},
		init(id) {
			this.queryEnumList()
			if (id) {
				cmsconfigInfo(id).then(res => {
					this.objInfo = res.data
					let valueTypeObj = this.ConfigValueType_cmsList.find(item => {
						return item.code == this.objInfo.valueType
					})
					this.objInfo.valueTypeName = valueTypeObj ? valueTypeObj.name : ""
					let tagGroupObj = this.TagGroup_cmsList.find(item => {
						return item.code == this.objInfo.tagGroup
					})
					this.objInfo.tagGroupName = tagGroupObj ? tagGroupObj.name : ""
				})
			}
			this.drawer = true
		},
		// 关闭抽屉
		handleClose(done) {
			done()
		},
	},
}
</script>
<style scoped>
.from-title {
	margin-bottom: 20px;
	padding: 0 20px 20px 20px;
	font-size: 16px;
	color: #17233d;
	border-bottom: 1px solid #eee;
}
.info-item {
	margin-bottom: 40px;
}

.form-item {
	margin-bottom: 20px;
	font-size: 14px;
}
.form-item-label {
	text-align: right;
	float: left;
	width: 25%;
}
.form-item-content {
	margin-left: 30%;
	width: 70%;
}
</style>
